<form class="form-inline" method="get">
    <div class="form-group col-xs-1">
        <div class="col-xs-12">
            <select class="form-control" name="status" id="status">
                <option value=''   {if isset($param['status']) && $param['status'] eq ''}selected{/if} >全部</option>
                <option value='1'  {if isset($param['status']) && $param['status'] eq '1'}selected{/if}>未处理</option>
                <option value='2' {if isset($param['status']) && $param['status'] eq '2'}selected{/if}>已处理</option>
            </select>
        </div>
    </div>
    <div class="form-group col-xs-1">
        <div class="col-xs-12">
            <select class="form-control" name="type" id="type">
                <option value=''   {if isset($param['type']) && $param['type'] eq ''}selected{/if} >全部</option>
                {foreach :config('work_sheet') as $key=>$val}
                <option value='{$key}' {if isset($param['type']) && $param['type'] eq $key}selected{/if} >{$val}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group col-xs-2">
        <div class="col-xs-12">
            <button type="submit" class="btn btn-success">
                确认搜索
            </button>
        </div>
    </div>
</form>
<hr>
<table class="table table-striped">
    <thead>
    <tr>
        <td>ID</td>
        <td>工单标题</td>
        <td>类型</td>
        <td>工单联系信息</td>
        <td>工单描述</td>
        <td>处理状态</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    {volist name="list" id="item"}
    <tr>
        <td>{$item.id}</td>
        <td>
            <p>{$item.title}</p>
        </td>
        <td>{:config('work_sheet')[$item.type]}</td>
        <td>{$item.link_info}</td>
        <td>{$item.desc}</td>
        <td>
            {if condition="$item['status'] == 1" } <label style='color:#ff9797'>未处理</label>{/if}
            {if condition="$item['status'] == 2" }<label style='color:#666'>已处理</label>{/if}
        </td>
        <td>
            <div class="btn-group">

                {if condition="$item['status'] == 1" }
                <button type="button" class="btn btn-default" onclick="solve('{$item.id}')">
                    处理
                </button>
                {/if}
                {if condition="$item['status'] == 2" }<label style='color:#666'>已处理</label>{/if}
            </div>
        </td>
    </tr>
    {/volist}
    </tbody>
</table>

<div class="row">
    <div class="col-xs-12" style="text-align: right;">
        {$list->render()}
    </div>
</div>
<script src="__PUBLIC__/vendors/select2/js/select2.min.js"></script>
<script type="application/javascript">
    $(function () {
        $("#status").select2({
            placeholder: "处理状态",
            allowClear: true
        });
        $("#type").select2({
            placeholder: "工单类型",
            allowClear: true
        });
    });
    
    function solve(id) {
        layer.confirm("确定处理此记录？", function (res) {
            $.ajax({
                url:"{:url('solveworksheet')}",
                data:{
                    "sheet_id":id
                },
                type:"post",
                dataType:"json",
                success:function (res) {
                    layer.msg(res.info);
                    setTimeout(function () {
                        location.reload()
                    }, 666)
                }
            })
        })
    }
</script>
